﻿using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using FastDev;
using UnityEngine;

public class Send1 : MonoBehaviour
{
    Thread thread1;
    Thread thread2;
    private void Start()
    {
        MsgManager.Instance.Dispatch(111, "hello");

        thread1 = new Thread(() =>
        {
            while (true)
            {
                Thread.Sleep(1000);
                MsgManager.Instance.Enqueue(222, "hello", " thread");
            }
        });
        thread1.Start();
    }

    float time = 0f;
    private void Update()
    {
        time += Time.deltaTime;
        if (time > 1)
        {
            MsgManager.Instance.Dispatch(111, "world","11111");
            time = 0;
        }
    }

    private void OnDestroy()
    {
        thread1.Abort();
    }


    [ContextMenu("GC")]
    private void GC()
    {
        System.GC.Collect();
    }

}
